//
//  WCBPayResultViewController.m
//  WeChatBuniess
//
//  Created by Guo Rui on 2017/12/19.
//  Copyright © 2017年 GR Harry. All rights reserved.
//

#import "WCBPayResultViewController.h"

@interface WCBPayResultViewController ()

@end

@implementation WCBPayResultViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    self.view.backgroundColor = [UIColor colorWithRed:0.94 green:0.94 blue:0.95 alpha:1.00];
    self.edgesForExtendedLayout = UIRectEdgeNone;
    self.title = @"支付完成";
    
    [self setupViews];
}

#pragma mark - Actions
- (void)remakeDidClick
{
    NSLog(@"%s", __func__);
}

- (void)logoutDidClick
{
    NSLog(@"%s", __func__);
}

#pragma mark - Private
- (void)setupViews
{
    CGFloat x, y, w, h, maxY;
    CGFloat width = CGRectGetWidth(self.view.frame);
    
    {
        UIView *topBackgroundView = [[UIView alloc] init];
        topBackgroundView.backgroundColor = [UIColor whiteColor];
        [self.view addSubview:topBackgroundView];
        
        x = y = 0;
        w = width;
        h = 220.f;
        topBackgroundView.frame = CGRectMake(x, y, w, h);
        
        maxY = y + h;
        
        UILabel *paySuccessLabel = [[UILabel alloc] init];
        paySuccessLabel.textAlignment = NSTextAlignmentCenter;
        paySuccessLabel.textColor = [UIColor blackColor];
        paySuccessLabel.font = [UIFont systemFontOfSize:28];
        paySuccessLabel.text = @"支付成功!";
        [topBackgroundView addSubview:paySuccessLabel];
        
        x = 30.f;
        y = 30.f;
        w = width - 2 * x;
        h = 40.f;
        paySuccessLabel.frame = CGRectMake(x, y, w, h);
        
        UILabel *descLabel = [[UILabel alloc] init];
        descLabel.textAlignment = NSTextAlignmentCenter;
        descLabel.textColor = [UIColor colorWithRed:0.40 green:0.40 blue:0.40 alpha:1.00];
        descLabel.font = [UIFont systemFontOfSize:24];
        descLabel.numberOfLines = 0;
        descLabel.text = @"您制作的微信书已经成功下单，我们将以最快的速度\n将书本邮寄到您的手中";
        [topBackgroundView addSubview:descLabel];
        
        x = 30.f;
        y = CGRectGetMaxY(paySuccessLabel.frame) + 15.f;
        w = width - 2 * x;
        h = CGRectGetHeight(topBackgroundView.frame) - 10.f - y;
        descLabel.frame = CGRectMake(x, y, w, h);
    }
    
    {
        UIButton *remakeButton = [UIButton buttonWithType:UIButtonTypeCustom];
        remakeButton.titleLabel.font = [UIFont systemFontOfSize:25];
        [remakeButton setTitleColor:[UIColor colorWithRed:0.11 green:0.62 blue:0.94 alpha:1.00] forState:UIControlStateNormal];
        [remakeButton setTitle:@"我要再做一本" forState:UIControlStateNormal];
        
        remakeButton.backgroundColor = [UIColor whiteColor];
        remakeButton.layer.borderColor = [UIColor colorWithRed:0.11 green:0.62 blue:0.94 alpha:1.00].CGColor;
        remakeButton.layer.borderWidth = 1.5;
        remakeButton.layer.cornerRadius = 5.f;
        remakeButton.layer.masksToBounds = YES;
        
        [remakeButton addTarget:self action:@selector(remakeDidClick) forControlEvents:UIControlEventTouchUpInside];
        
        [self.view addSubview:remakeButton];
        
        x = 60.f;
        y = maxY + 50.f;
        w = width - 2 * x;
        h = 60.f;
        remakeButton.frame = CGRectMake(x, y, w, h);
        
        maxY = y + h;
        
        UIButton *logoutButton = [UIButton buttonWithType:UIButtonTypeCustom];
        logoutButton.titleLabel.font = [UIFont systemFontOfSize:25];
        [logoutButton setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
        [logoutButton setTitle:@"退出并清空微信数据" forState:UIControlStateNormal];
        
        logoutButton.backgroundColor = [UIColor colorWithRed:0.11 green:0.62 blue:0.94 alpha:1.00];
        logoutButton.layer.cornerRadius = 5.f;
        logoutButton.layer.masksToBounds = YES;
        
        [logoutButton addTarget:self action:@selector(logoutDidClick) forControlEvents:UIControlEventTouchUpInside];
        
        [self.view addSubview:logoutButton];
        
        x = 60.f;
        y = maxY + 30.f;
        w = width - 2 * x;
        h = 60.f;
        logoutButton.frame = CGRectMake(x, y, w, h);
    }
}

@end
